package org.sbbs.app.demo.webapp.action;

import org.sbbs.app.demo.service.DemoTreeManager;
import org.sbbs.base.search.PropertySearchBuilder;
import org.sbbs.base.webapp.action.BaseGridAction;

import com.googlecode.genericdao.search.Search;
import com.googlecode.genericdao.search.SearchResult;

public class DemoTreeDwzPagedAction
    extends BaseGridAction {
    @Override
    public String gridPageList() {
        Search search = PropertySearchBuilder.BuildSearch( getRequest() );
        SearchResult srt = this.demoTreeManager.searchAndCount( search );
        this.setPageList( srt.getResult() );
        this.records = srt.getTotalCount();
        this.total = getTotlePage( records, search.getMaxResults() );
        this.page = search.getPage() + 1;
        this.setStatusCode( AJAX_STATUS_SUCCESS );
        this.setMessage( "load success,dwz message test." );
        return this.SUCCESS;
    }

    public String rebuildTree() {
        this.demoTreeManager.reBuildAllTree();
        this.setStatusCode( AJAX_STATUS_SUCCESS );
        this.setMessage( "rebuild nest set tree success." );
        return SUCCESS;
    }

    DemoTreeManager demoTreeManager;

    public DemoTreeManager getDemoTreeManager() {
        return demoTreeManager;
    }

    public void setDemoTreeManager( DemoTreeManager demoTreeManager ) {
        this.demoTreeManager = demoTreeManager;
    }

}
